package com.hamizhong.iflowers.web.action.admin.statics;

import net.sf.json.JSONObject;

import com.hamizhong.iflowers.service.IFestivalService;
import com.hamizhong.iflowers.utils.MyConstants;
import com.hamizhong.iflowers.web.base.MyBaseAjaxAction;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.FestivalVO;
import com.hamizhong.iflowers.web.vo.IObjectVO;

public class AjaxAddFestivalAction extends MyBaseAjaxAction {

	private IFestivalService iFestivalService = null;
	
	public IFestivalService getiFestivalService() {
		return iFestivalService;
	}
	public void setiFestivalService(IFestivalService iFestivalService) {
		this.iFestivalService = iFestivalService;
	}
	
	@Override
	protected JSONObject doRequest() {
		logger.info("...invoke...AjaxQueryFestivalAction...");
		String festivalName = getRQ().getParameter("festivalName");
		String festivalId = getRQ().getParameter("festivalId");
		String sortId = getRQ().getParameter("sortId");
		String remarks = getRQ().getParameter("remarks");
		IOPResultDto<IObjectVO> resultDto = new IOPResultDto<IObjectVO>();
		FestivalVO festivalVO = new FestivalVO();
		festivalVO.setFestivalName(festivalName);
		festivalVO.setFestivalId(festivalId);
		festivalVO.setSortId(Integer.valueOf(sortId));
		festivalVO.setRemarks(remarks);
		resultDto = iFestivalService.addFestival(festivalVO);
		JSONObject jo = new JSONObject();
		if(resultDto.isSuccess()) {
			jo.put("result", MyConstants.AJAX_SUCCESS);
		}else {
			jo.put("result", MyConstants.AJAX_FAILED_ALERT);
			jo.put("msg", resultDto.getErrorMSG());
		}
		return jo;
	}

}
